<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<script type="text/javascript">

$(function(){
	//初始化表单验证
	$("#addForm").validate({
		rules: {
			gbprice: {isMoney: true},
		},
		messages: {
			name: {required: "请输入商品标题"},
		},
		submitHandler:function(form){
			$(form).ajaxSubmit({
				success:function(data){
					switch(data.flag){
					case 2:
						Kit.alert("该模板已添加,请重新编辑模板名称");return;
					/* case 3:
						Kit.alert("选择分类");return;
					case 4:
						Kit.alert("选择分类");return; */
					/* case -1:
						Kit.alert("网络繁忙...，请重试");return;  */
					case  -1:
						/* dataPaginator.loadPage(1); */
						addDialog.close();
						return;
					}
				}
			});
		}
	});
}); 
/* 点击新增规格选项 */ 
$(document).ready(function(){
    $("#addTemplate").click(function(){
    	var tr="<tr><td><input class=\"form-control\" name=\"iname\" placeholder=\"属性名称\">"+
    		"<td><input class=\"form-control\" name=\"idetail\" placeholder=\"属性值\">"+
			"</td><td><input type=\"checkbox\" name=\"check\" checked=\"checked\" />"+
			"</td></tr>";
			$("#table").append(tr);
    });
    $("#deleteTemplate").click(function(){
        var check = document.getElementsByName("check");
        for(var i=0;i<check.length;i++){
            if(check[i].checked){
                 document.getElementById('table').deleteRow(i);
                 i--;
            }
        }
    });
})

</script>
<form id="addForm" action="${BASE_PATH}/bus/goods/template/doAdd" method="post" class="form-horizontal" >
	<!-- 编辑窗口 -->	
	
		<%-- <div>
			<label class="search-label">商品分类：</label>
			<select id="sCategoryonid" name="sCategoryonid" class="selectpicker pull-left p-l-5" data-width="120px" data-url="${BASE_PATH}/api/category" data-isfirst="true" data-next="#sCategorytwid" data-key="id:name"></select>
			<select id="sCategorytwid" name="sCategorytwid" class="selectpicker pull-left p-l-5" data-width="120px" data-url="${BASE_PATH}/api/categorys/{value}"  data-key="id:name"></select>
			<div class="clearfix"></div>
		 </div> --%>
		 <div>
	 		<label class="search-label">关联规格：</label>
			<select id="specids" name="specids" class="selectpicker pull-left p-l-5" multiple="multiple" data-width="260px">
				<c:forEach items="${listSpec}" var="spec">
					<option value="${spec.id}">${spec.specName}</option>
				</c:forEach>
			</select>				 	
			<div class="clearfix"></div>
		</div>
		<div>
			<label class="search-label">模板名称：</label>
				 <div>
		        	<input type="text" id="name" name="name" class="form-control" placeholder="请输入模板名称">
			    </div>
		</div>
		<div class="row">
		<div class="col-lg-6"><button class="btn btn-primary col-sm-3 pull-right" type="submit" autocomplete="off" >提交</button></div>
		<div class="col-lg-6"><button class="btn btn-default col-sm-3 pull-left"  type="button" onclick="javascript:addDialog.close();" autocomplete="off">取消</button></div>
	</div>
</form>